package com.xbongbong.saas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @description: 套餐支付状态枚举
 * @Author: hongxiao
 * @date: 2019-01-13 21:47
 */
@Getter
public enum FeePayStatusEnum {
    /**
     * 套餐支付状态
     */
    WAIT_PAY(0, "enum.feePayStatus.name.wait_pay"),
    SUCCESS_PAY(1, "enum.feePayStatus.name.success_pay"),
    FAILURE_PAY(2, "enum.feePayStatus.name.failure_pay"),
    ;

    /**
     * 套餐支付状态
     */
    private int code;
    /**
     * 套餐支付状态名称
     */
    private String name;

    FeePayStatusEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static FeePayStatusEnum getByCode(int code) {
        for (FeePayStatusEnum cacheCode : values()) {
            if (cacheCode.getCode() == code) {
                return cacheCode;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

}
